package cn.it.utils;

import cn.it.anno.MyComponent;

import java.sql.Connection;
import java.sql.SQLException;

@MyComponent
public class ConnectionUtils {

    private ThreadLocal<Connection> local = new ThreadLocal<>();

    public Connection getCurrentConn() throws SQLException {
        Connection conn = local.get();
        if (conn==null){
            conn = DruidUtils.getInstance().getConnection();
            local.set(conn);
        }
        return conn;
    }

}
